<template>
	<view class="page-content">
		<view class="top-layout" :style="{'backgroundImage': 'url('+asserts.ic_mine_tip_bg+')'}">
			<view class="user-info">
				<view class="photo-layout">
					<image class="user-photo" :src="getAvator(assistantInfo.sculptureUrl)" mode="aspectFill"></image>
					<image class="user-type-img" :src="assistantInfo.picture"></image>
				</view>
				<view class="right-layout">
					<view class="user-name">{{assistantInfo.name}}</view>
					<view class="user-des">{{assistantInfo.introductory || '这个人很懒，什么也不想写'}}</view>
				</view>
				<image class="qr-code-img" :src="ftpUrl + '/ic_qr_code_bg.png'" @click="qrCodeClick"></image>
			</view>
			<view class="time-layout">
				<view class="left-layout">
					<view class="time">服务时间：{{getWorkTime(assistantInfo.businessHoursStart, assistantInfo.businessHoursEnd)}}</view>
					<assistant-computed-info type="tag4" :labelDescList="assistantInfo.labelDescList"></assistant-computed-info>
				</view>
				<view class="eidt-btn" @click="editInfoClick">编辑资料</view>
			</view>
			<view class="tab-row">
				<view class="tab-item" :style="{'backgroundImage': 'url('+asserts.ic_mine_tab_bg1+')'}" @click="mineSquareClick">
					<view class="title">{{assistantInfo.showVideoTotal || 0}}</view>
					<view class="content">我的广场</view>
					<view class="tips">多发布广场视频有助于曝光</view>
					<view class="btn1">发视频</view>
				</view>
				<view style="width: 14rpx;"></view>
				<view class="tab-item" :style="{'backgroundImage': 'url('+asserts.ic_mine_tab_bg2+')'}" @click="mineFansClick" v-if="false">
					<view class="title">12</view>
					<view class="content">我的粉丝</view>
					<view class="tips">看看最近谁关注关注了你</view>
					<view class="btn2">去查看</view>
				</view>
				<view style="width: 14rpx;"></view>
				<view class="tab-item" :style="{'backgroundImage': 'url('+asserts.ic_mine_tab_bg3+')'}" @click="walletClick">
					<view class="title">¥{{walletInfo.totalAmount||0}}</view>
					<view class="content">我的钱包</view>
					<view class="tips">金额可提现至本人银行卡</view>
					<view class="btn2">去提现</view>
				</view>
			</view>
		</view>
		<view class="service-order">
			<view class="title-row" @click="mineOrderClick(0)">
				<view class="title">服务订单</view>
				<view class="all">全部</view>
				<image class="img" :src="asserts.ic_arrow_right"></image>
			</view>
			<view class="item-row">
				<view class="order-item" @click="mineOrderClick(0)">
					<image :src="asserts.ic_order_status"></image>
					<view>待接单</view>
				</view>
				<view class="order-item" @click="mineOrderClick(1)">
					<image :src="asserts.ic_order_status4"></image>
					<view>待服务</view>
				</view>
				<view class="order-item" @click="mineOrderClick(2)">
					<image :src="asserts.ic_order_status3"></image>
					<view>服务中</view>
				</view>
				<view class="order-item" @click="mineOrderClick(3)">
					<image :src="asserts.ic_order_status2"></image>
					<view>服务完成</view>
				</view>
				<view class="order-item" @click="mineOrderClick(5)">
					<image :src="asserts.ic_order_status1"></image>
					<view>已拒绝</view>
				</view>
			</view>
		</view>
		<view class="other-layout">
			<view class="title">其他</view>
			<view class="menu-row">
				<view class="menu-item" v-if="false">
					<image :src="asserts.ic_service1"></image>
					<view>服务合同</view>
				</view>
				<view class="menu-item" @click="serviceAgreementClick">
					<image :src="asserts.ic_service2"></image>
					<view>用户协议</view>
				</view>
				<view class="menu-item" @click="privacyPoliciesClick">
					<image :src="asserts.ic_service3"></image>
					<view>隐私政策</view>
				</view>
				<view class="menu-item" @click="accountSecurityClick">
					<image :src="asserts.ic_service4"></image>
					<view>账号安全</view>
				</view>
			</view>
		</view>
		<assistant-qr-code-popup ref="qrCodePopup"></assistant-qr-code-popup>
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				assistantInfo: {},
				walletInfo: {},
			}
		},
		computed: {
			getAvator(){
				return (avator) => {
					if(avator){
						return avator
					}else{
						return this.asserts.ic_avatar_default
					}
				}
			},
			getWorkTime(){
				return (start, end) => {
					if(start && end){
						return `${start}-${end}`
					}else{
						return '暂未设置'
					}
				}
			}
		},
		mounted() {
			this.getAssistantDetailToken()
			this.getUserWallet()
		},
		methods: {
			//助教详情
			getAssistantDetailToken(){
				this.requestCenter.getAssistantDetailToken().then(res => {
					this.assistantInfo = res
				})
			},
			
			//我的钱包
			getUserWallet(){
				this.requestCenter.getUserWallet().then(res => {
					this.walletInfo = res
				})
			},
			
			//点击编辑信息
			editInfoClick(){
				uni.navigateTo({
					url: '/pages/assistant-personal-info/assistant-personal-info'
				})
			},
			
			//我的广场点击
			mineSquareClick(){
				uni.navigateTo({
					url: '/pages/mine-square/mine-square?userId=' + this.assistantInfo.id
				})
			},
			
			//点击我的粉丝
			mineFansClick(){
				uni.navigateTo({
					url: '/pages/assistant-fans/assistant-fans'
				})
			},
			
			//点击钱包
			walletClick(){
				uni.navigateTo({
					url: '/pages/mine-wallet/mine-wallet'
				})
			},
			
			//点击二维码
			qrCodeClick(){
				this.$refs.qrCodePopup.show()
			},
			
			//点击我的订单
			mineOrderClick(index){
				uni.navigateTo({
					url: '/pages/assistant-order-list/assistant-order-list?index=' + index
				})
			},
			
			//用户协议
			serviceAgreementClick(){
				uni.navigateTo({
					url: "/pages/service-agreement/service-agreement"
				})
			},
			
			//隐私政策
			privacyPoliciesClick(){
				uni.navigateTo({
					url: "/pages/privacy-policies/privacy-policies"
				})
			},
			
			//账号安全
			accountSecurityClick(){
				uni.navigateTo({
					url: '/pages/account-security/account-security'
				})
			},
		}
	}
</script>

<style scoped lang="less">
	.page-content {
		width: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	
	.top-layout {
		display: flex;
		flex-direction: column;
		background-repeat: no-repeat;
		background-size: 100% 100%;
		/* #ifdef H5 */
		padding: 50rpx 32rpx 0 32rpx;
		/* #endif */
		/* #ifndef H5 */
		padding: 180rpx 32rpx 0 32rpx;
		/* #endif */
		box-sizing: border-box;
	}
	
	.user-info {
		display: flex;
		flex-direction: row;
		align-items: center;
	
		.photo-layout {
			position: relative;
			.user-photo {
				width: 112rpx;
				height: 112rpx;
				border-radius: 50%;
			}
	
			.user-type-img {
				width: 113rpx;
				height: 40rpx;
				position: absolute;
				bottom: -10rpx;
				/* #ifdef H5 */
				left: 0;
				/* #endif */
			}
		}
	
		.right-layout {
			flex: 1;
			display: flex;
			flex-direction: column;
			margin-left: 18rpx;
	
			.user-name {
				font-size: 40rpx;
				color: #021624;
				line-height: 48rpx;
				font-weight: 500;
			}
	
			.user-des {
				font-size: 24rpx;
				color: #585F70;
				line-height: 48rpx;
				margin-top: 8rpx;
				overflow: hidden;
				-webkit-line-clamp: 1;
				text-overflow: ellipsis;
				display: -webkit-box;
				-webkit-box-orient: vertical;
			}
		}
		.qr-code-img{
			width: 64rpx;
			height: 64rpx;
			margin-right: 16rpx;
		}
	}
	
	.time-layout {
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-top: 50rpx;
	
		.left-layout {
			flex: 1;
			display: flex;
			flex-direction: column;
	
			.time {
				color: #585F70;
				font-size: 24rpx;
				line-height: 48rpx;
				margin-bottom: 16rpx;
			}
		}
	
		.eidt-btn {
			width: 176rpx;
			height: 64rpx;
			line-height: 64rpx;
			text-align: center;
			border-radius: 40rpx;
			border: 1rpx solid #01CBFF;
			font-size: 28rpx;
			color: #01CBFF;
		}
	}
	
	.tab-row {
		display: flex;
		flex-direction: row;
		margin-top: 32rpx;
	
		.tab-item {
			flex: 1;
			padding: 32rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			background-repeat: no-repeat;
			background-size: 100% 100%;
	
			.title {
				font-size: 32rpx;
				color: #021624;
				line-height: 48rpx;
				font-weight: 500;
			}
	
			.content {
				font-size: 28rpx;
				color: #021624;
				line-height: 48rpx;
				margin-top: 8rpx;
			}
	
			.tips {
				color: #ABAFB7;
				font-size: 22rpx;
				line-height: 28rpx;
				margin-top: 16rpx;
				margin-bottom: 16rpx;
			}
	
			.btn1 {
				width: 156rpx;
				height: 52rpx;
				line-height: 52rpx;
				background: #01CBFF;
				border-radius: 8rpx;
				font-size: 24rpx;
				color: #FFFFFF;
				text-align: center;
			}
	
			.btn2 {
				height: 52rpx;
				line-height: 52rpx;
				background: #F2F1F6;
				border-radius: 8rpx;
				font-size: 24rpx;
				color: #021624;
				text-align: center;
			}
		}
	}
	
	.service-order {
		width: calc(100% - 64rpx);
		background: #FFFFFF;
		border-radius: 16rpx;
		padding: 28rpx 40rpx 32rpx 32rpx;
		box-sizing: border-box;
		margin-top: 32rpx;
	
		.title-row {
			display: flex;
			flex-direction: row;
			align-items: center;
			margin-bottom: 32rpx;
	
			.title {
				flex: 1;
				font-size: 32rpx;
				color: #021624;
				line-height: 48rpx;
				font-weight: 500;
			}
	
			.all {
				font-size: 28rpx;
				color: #ABAFB7;
				line-height: 44rpx;
				margin-right: 16rpx;
			}
	
			.img {
				width: 20rpx;
				height: 20rpx;
			}
		}
	
		.item-row {
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			box-sizing: border-box;
			.order-item {
				display: flex;
				flex-direction: column;
				font-size: 24rpx;
				color: #585F70;
				align-items: center;
				image {
					width: 64rpx;
					height: 64rpx;
					margin-bottom: 20rpx;
				}
			}
		}
	}
	
	.other-layout {
		width: calc(100% - 64rpx);
		background: #FFFFFF;
		border-radius: 16rpx;
		padding: 44rpx 40rpx 32rpx 40rpx;
		box-sizing: border-box;
		margin-top: 16rpx;
	
		.title {
			font-size: 32rpx;
			color: #021624;
			line-height: 48rpx;
			font-weight: 500;
			margin-bottom: 32rpx;
		}
		.menu-row {
			display: flex;
			flex-direction: row;
			.menu-item {
				display: flex;
				flex-direction: column;
				font-size: 24rpx;
				color: #585F70;
				align-items: center;
				margin-right: 76rpx;
				image {
					width: 88rpx;
					height: 88rpx;
					margin-bottom: 16rpx;
				}
			}
		}
	}
</style>
